import type { ProColumns } from '@ant-design/pro-table';

// 定义请求返回数据类型
export type ColumnsItem = {
  merchant: string,
  MCHID: string,
  withdrawAmount: number,
  withdrawCurrency: string,
  withdrawWay: string,
  handlingCharge: number,
  handlingChargeCurrency: string,
  amountReceived: number,
  amountReceivedCurrency: string,
  exchangeRate: number,
  bothCurrencies: string,
  serialNumber: string,
  created_at: string,
  result: string
}

// 定义表头
let columnsData: ProColumns<ColumnsItem>[] = [
  {
    title: '折扣发放商家',
    hideInTable: true,
    dataIndex: 'MCHID',
  },
  {
    title: '享有折扣会员',
    dataIndex: 'serialNumber',
    hideInTable: true,
  },
  {
    title: '享有折扣推荐人',
    dataIndex: 'serialNumber',
    hideInTable: true,
  },
  {
    title: '发放结果',
    dataIndex: 'result',
    hideInTable: true,
    valueType: 'select',
    valueEnum: {
      all: { text: '全部', status: 'Default' },
      processing: { text: '交易中', status: 'Processing' },
      success: { text: '成功', status: 'Success' },
      failure: { text: '失败', status: 'Failure ' },
    },
  },
  {
    title: '折扣发放日期',
    dataIndex: 'created_at',
    hideInTable: true,
    valueType: 'dateRange',
    search: {
      transform: (value) => {
        return {
          startTime: value[0],
          endTime: value[1],
        };
      },
    },
  },

  // 上方查询，下方表头
  {
    title: '关联流水号',
    width: 100,
    fixed: 'left',
    dataIndex: 'index',
    valueType: 'indexBorder',
  },
  {
    title: '折扣编码',
    width: 80,
    hideInSearch: true,
    dataIndex: 'withdrawAmount',
  },
  {
    title: '折扣发放总额',
    width: 100,
    hideInSearch: true,
    dataIndex: 'merchant',
    ellipsis: true,
  },
  {
    title: '币种',
    width: 45,
    hideInSearch: true,
    dataIndex: 'withdrawCurrency',
  },
  {
    title: '获赠者',
    width: 80,
    hideInSearch: true,
    dataIndex: 'bothCurrencies',
  },
  {
    title: '获赠者类别',
    width: 100,
    hideInSearch: true,
    dataIndex: 'bothCurrencies',
  },
  {
    title: '获赠金额',
    width: 100,
    hideInSearch: true,
    dataIndex: 'withdrawWay',
  },
  {
    title: '币种',
    width: 45,
    hideInSearch: true,
    dataIndex: 'handlingChargeCurrency',
  },
  {
    title: '交易流水号',
    width: 100,
    hideInSearch: true,
    dataIndex: 'bothCurrencies',
  },
  {
    title: '折扣发放时间',
    width: 150,
    hideInSearch: true,
    dataIndex: 'created_at',
  },
  {
    title: '折扣编码',
    width: 80,
    hideInSearch: true,
    dataIndex: 'bothCurrencies',
  },
  {
    title: '交易结果',
    hideInSearch: true,
    dataIndex: 'result',
    width: 75,
  },
  {
    title: '失败原因',
    width: 80,
    hideInSearch: true,
    dataIndex: 'bothCurrencies',
  },
  {
    title: '操作',
    width: 80,
    fixed: 'right',
    align: 'center',
    valueType: 'option',
  }
]
export default columnsData;
